package com.manage.project.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.framework.aspectj.lang.annotation.Log;
import com.manage.framework.web.controller.BaseController;
import com.manage.framework.web.domain.AjaxResult;
import com.manage.framework.aspectj.lang.enums.BusinessType;
import com.manage.project.biz.domain.BizXiaofang;
import com.manage.project.biz.service.IBizXiaofangService;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.framework.web.page.TableDataInfo;

/**
 * 消防设施Controller
 * 
 * @author liang
 */
@RestController
@RequestMapping("/biz/xiaofang")
public class BizXiaofangController extends BaseController
{
    @Autowired
    private IBizXiaofangService bizXiaofangService;

    /**
     * 查询消防设施列表
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizXiaofang bizXiaofang)
    {
        startPage();
        List<BizXiaofang> list = bizXiaofangService.selectBizXiaofangList(bizXiaofang);
        return getDataTable(list);
    }

    /**
     * 导出消防设施列表
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:export')")
    @Log(title = "消防设施", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizXiaofang bizXiaofang)
    {
        List<BizXiaofang> list = bizXiaofangService.selectBizXiaofangList(bizXiaofang);
        ExcelUtil<BizXiaofang> util = new ExcelUtil<BizXiaofang>(BizXiaofang.class);
        return util.exportExcel(list, "消防设施数据");
    }

    /**
     * 获取消防设施详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:query')")
    @GetMapping(value = "/{field1}")
    public AjaxResult getInfo(@PathVariable("field1") String field1)
    {
        return AjaxResult.success(bizXiaofangService.selectBizXiaofangByField1(field1));
    }

    /**
     * 新增消防设施
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:add')")
    @Log(title = "消防设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizXiaofang bizXiaofang)
    {
        return toAjax(bizXiaofangService.insertBizXiaofang(bizXiaofang));
    }

    /**
     * 修改消防设施
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:edit')")
    @Log(title = "消防设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizXiaofang bizXiaofang)
    {
        return toAjax(bizXiaofangService.updateBizXiaofang(bizXiaofang));
    }

    /**
     * 删除消防设施
     */
//    @PreAuthorize("@ss.hasPermi('system:xiaofang:remove')")
    @Log(title = "消防设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{field1s}")
    public AjaxResult remove(@PathVariable String[] field1s)
    {
        return toAjax(bizXiaofangService.deleteBizXiaofangByField1s(field1s));
    }
}
